<#global staticPath = "${request.contextPath}">
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1, user-scalable=no, minimal-ui" name="viewport">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta http-equiv='Content-type' content='text/html; charset=utf-8'/>
	<meta name='format-detection' content='telephone=no'/>
	<meta name='apple-touch-fullscreen' content='yes'/>
	<title>车次管理</title>
	<link rel="stylesheet" href="${staticPath}/css/index.css">
	<link rel="stylesheet" href="${staticPath}/css/alertify/alertify.core.css">
	<link rel="stylesheet" href="${staticPath}/css/alertify/alertify.default.css">
	
	<script type="text/javascript" src="${staticPath}/js/jquery-1.10.2.min.js"></script>
	<script type="text/javascript" src="${staticPath}/js/parsley.min.js"></script>
	<script type="text/javascript" src="${staticPath}/js/alertify/alertify.min.js"></script>
	
	
	
	
	
	
	
	
	<link href="${staticPath}/css/bootstrap-datetimepicker.css" rel="stylesheet" type="text/css" />
	<script src="${staticPath}/js/bootstrap-datetimepicker.js" type="text/javascript"></script>
	
	
</head>
<body>
	<header>
		<div class="header_box">
			<div class="header_b">
				<img src="${staticPath}/image/tielu.png" alt="">
				<div class="header_bcenter"><#if train??>编辑<#else>新增</#if>车次</div>
			</div>
		</div>
	</header>
	<div class="content">
		<div class="content_bg">
			<div class="content_edit_search">
				<div class="content_edit_seatitle"><img src="${staticPath}/image/edit.png" alt="">编辑</div>
				<div class="content_edit_seakuang">
					<form id="trainForm" method="post" >
					<div class="content_edit_seaever">
						<span>车次:</span>
						<input type="text" name= "trainName" value="${(train.trainName)!}">
					</div>
						<input type="hidden" name="trainId" value="${(train.trainId)!}"/>
					<div class="content_edit_seaever">
						<span>始发站:</span>
						<select name="startStationId" id="startStationId">
							<option value="0" >无</option>
							<#if stationList?? && stationList?size gt 0>
								<#list stationList as station>
									 <option value="${(station.stationId)!}" <#if (train.startStationId)?? && train.startStationId == station.stationId>selected</#if>>${(station.stationName)!}</option>
								</#list>
							</#if>
						</select>
					</div>
					<div class="content_edit_seaever">
						<span>后方站:</span>
						<select name="afterStationId" id="afterStationId">
							<option value="0" >无</option>
							<#if stationList?? && stationList?size gt 0>
								<#list stationList as station>
									 <option value="${(station.stationId)!}" <#if (train.afterStationId)?? && train.afterStationId == station.stationId>selected</#if>>${(station.stationName)!}</option>
								</#list>
							</#if>
						</select>
					</div>
					<div class="content_edit_seaever">
						<span>前方站:</span>
						<select name="frontStationId" id="frontStationId">
							<option value="0" >无</option>
							<#if stationList?? && stationList?size gt 0>
								<#list stationList as station>
									 <option value="${(station.stationId)!}" <#if (train.frontStationId)?? && train.frontStationId == station.stationId>selected</#if>>${(station.stationName)!}</option>
								</#list>
							</#if>
						</select>
					</div>
					<div class="content_edit_seaever">
						<span>终点站:</span>
						<select name="endStationId" id="endStationId">
							<option value="0" >无</option>
							<#if stationList?? && stationList?size gt 0>
								<#list stationList as station>
									 <option value="${(station.stationId)!}" <#if (train.endStationId)?? && train.endStationId == station.stationId>selected</#if>>${(station.stationName)!}</option>
								</#list>
							</#if>
						</select>
					</div>
					<div class="content_edit_seaever">
						<span>始发时间:</span>
						<input type="text" name="startTimeStr" id="startTimeStr" value="${(train.startTime?string('HH:mm:ss'))!}">
					</div>
					<div class="content_edit_seaever">
						<span>终点时间:</span>
						<input type="text" name="endTimeStr" id="endTimeStr" value="${(train.endTime?string('HH:mm:ss'))!}">
					</div>
					<div class="content_edit_seaever">
						<span>到站时间:</span>
						<input type="text" name="reachTimeStr" value="${(train.reachTime?string('HH:mm:ss'))!}">
					</div>
					<div class="content_edit_seaever">
						<span>离站时间:</span>
						<input type="text" name="leaveTimeStr" value="${(train.leaveTime?string('HH:mm:ss'))!}">
					</div>
					
					
					<div class="content_edit_seaever">
						<span>接车股道:</span>
						<select name="pickUpTrack" id="pickUpTrack">
							<option value="0" >无</option>
							<#if trackList?? && trackList?size gt 0>
								<#list trackList as track>
									 <option value="${(track.trackId)!}" <#if (train.pickUpTrack)?? && train.pickUpTrack == track.trackId>selected</#if>>${(track.trackOrder)!}G</option>
								</#list>
							</#if>
						</select>
					</div>
					<div class="content_edit_seaever">
						<span>发车股道:</span>
						<select name="leaveTrack" id="leaveTrack">
							<option value="0" >无</option>
							<#if trackList?? && trackList?size gt 0>
								<#list trackList as track>
									 <option value="${(track.trackId)!}" <#if (train.leaveTrack)?? && train.leaveTrack == track.trackId>selected</#if>>${(track.trackOrder)!}G</option>
								</#list>
							</#if>
						</select>
					</div>
					<div class="content_edit_seaever">
						<span>接车路径序列:</span>
						<input type="text" name="pickUpSequence" value="${(train.pickUpSequence)!}G">
					</div>
					<div class="content_edit_seaever">
						<span>发车路径序列:</span>
						<input type="text" name="leaveSequence" value="${(train.leaveSequence)!}G">
					</div>
					 <div class="content_edit_seaever">
						<span>是否上水:</span>
						<select name="isAddWater" id="isAddWater">
							<option value="0" <#if (train.isAddWater)?? && train.isAddWater == 0>selected</#if>>否</option>
							<option value="1" <#if (train.isAddWater)?? && train.isAddWater == 1>selected</#if>>是</option>
						</select>
					</div>
					 <div class="content_edit_seaever">
						<span>是否吸污:</span>
						<select name="isDealRubbisk" id="isDealRubbisk">
							<option value="0" <#if (train.isDealRubbisk)?? && train.isDealRubbisk == 0>selected</#if>>否</option>
							<option value="1" <#if (train.isDealRubbisk)?? && train.isDealRubbisk == 1>selected</#if>>是</option>
						</select>
					</div>
					<div class="content_edit_seaever">
						<span>编组数:</span>
						<input type="text" name="grandUpNum" value="${(train.grandUpNum)!}">
					</div>
					<div class="content_edit_seaever">
						<span>编组类型:</span>
						<select name="grandUpType" id="grandUpType">
							<option value="1" <#if (train.grandUpType)?? && train.grandUpType == 1>selected</#if>>短编</option>
							<option value="2" <#if (train.grandUpType)?? && train.grandUpType == 2>selected</#if>>长编</option>
						</select>
					</div>
					<div class="content_edit_seaever">
						<span>定编数:</span>
						<input type="text" name="allocationNum" value="${(train.allocationNum)!}">
					</div>
					
					<div class="content_edit_seaever">
						<span>担当局:</span>
						<select name="bearDepartmentId" id="bearDepartmentId">
							<option value="0" >无</option>
							<#if departmentList?? && departmentList?size gt 0>
								<#list departmentList as department>
									 <option value="${(department.id)!}" <#if (train.bearDepartmentId)?? && train.bearDepartmentId == department.id>selected</#if>>${(department.departName)!}</option>
								</#list>
							</#if>
						</select>
					</div>
					</form>
					<div class="content_edit_seaever_btn" onclick="save();" >保存</div>
					<div class="content_edit_seaever_btn hui" onclick="history.go(-1);">返回</div>
				</div>
			</div>
		</div>
	</div>
	<script src="${staticPath}/js/android/cordova.js"></script>
	
	<script>
		function save(){
			
			if($('#trainForm').parsley().validate()){
				$.ajax({
					cache: true,
					type: "POST",
					url:"/train/save",
					data:$('#trainForm').serialize(),
					async: false,
					error: function(request) {
						alertify.alert("错误：服务器异常！");
					},
					success: function(data) {
						if(data.success){
							alertify.alert("操作成功！",function(e){location.href="/train/list";});
						}
						else{
							alertify.alert("错误:" + data.message);
						}   
					}
				});
			}
		}
		
		
		//$("#startTimeStr").timepicker();
		/*
		$('#endTimeStr').datetimepicker({
			hour: 22,
			minute: 00,
			timeFormat: "HH:mm",
			dateFormat: "yy-mm-dd",
			minDate: new Date()
			//maxDate: new Date()
		});
		*/
		// $("#startTime").val(nowTime).timepicker('setTime', nowTime);
		 
		 
		 
		 
		$(function() {
				$('#endTimeStr').timepicker({
				defaultTime:'9:00',
				showMeridian:false,
				});
			});

		 
		 
		 
		 
		 
		 
	</script>
</body>
</html>